#!/usr/bin/python

import sys 

cat_hash = {}

for eachLine in sys.stdin:
    eachLine = eachLine.strip()

    category = eachLine.split("\t")[0]
    art_name = eachLine.split("\t")[1]
    
    if(cat_hash.has_key(category) == False):
        cat_hash[category] = []
        
    cat_hash[category].append(art_name)


#Emmit key value pairs
for eachCategory in cat_hash:
    print eachCategory+"\t"+str(len(cat_hash[eachCategory]))+"\t"+"\t".join(cat_hash[eachCategory])

    
